luci-mod-network,-status: show DHCPv6 lease IAID
authorDavid Härdeman <[email protected]>
Tue, 16 Sep 2025 16:27:56 +0000 (18:27 +0200)
committerPaul Donald <[email protected]>
Mon, 22 Sep 2025 16:16:07 +0000 (18:16 +0200)
The IAID is important information as it allows the user to know which
interface on the client device a given DHCPv6 lease corresponds to.
odhcpd already exposes this information (e.g. via "ubus call dhcp
ipv6leases"), but it would be good to have access to the same
information via the web interface, especially since odhcpd does take the
IAID into account when allocating addresses.

Signed-off-by: David Härdeman <[email protected]>
libs/rpcd-mod-luci/src/luci.c
modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js
modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/40_dhcp.js

index d9e2ab79ce6db31a7643a242124a96f427103226..7cb56ae2afa56965dbc5d1728e616842dd1c4ddb 100644 (file)
@@ -355,6 +355,7 @@ struct lease_entry {
        struct ether_addr mac;
        char *hostname;
        char *duid;
+       char *iaid;
        union {
                struct in_addr in;
                struct in6_addr in6;
@@ -487,16 +488,14 @@ lease_next(void)
                                strtok(NULL, " \t\n"); /* iface */
 
                                e.duid = strtok(NULL, " \t\n"); /* duid */
-
                                if (!e.duid)
                                        continue;
 
-                               p = strtok(NULL, " \t\n"); /* iaid */
-
-                               if (!p)
+                               e.iaid = strtok(NULL, " \t\n"); /* iaid */
+                               if (!e.iaid)
                                        continue;
 
-                               if (!strcmp(p, "ipv4")) {
+                               if (!strcmp(e.iaid, "ipv4")) {
                                        e.af = AF_INET;
                                        e.mask = 32;
                                }
@@ -597,6 +596,7 @@ lease_next(void)
 
                                e.hostname = strtok(NULL, " \t\n");
                                e.duid     = strtok(NULL, " \t\n");
+                               e.iaid     = NULL;
 
                                if (!e.hostname || !e.duid)
                                        continue;
@@ -1964,6 +1964,9 @@ rpc_luci_get_dhcp_leases(struct ubus_context *ctx, struct ubus_object *obj,
                        if (lease->duid)
                                blobmsg_add_string(&blob, "duid", lease->duid);
 
+                       if (lease->iaid)
+                               blobmsg_add_string(&blob, "iaid", lease->iaid);
+
                        inet_ntop(lease->af, &lease->addr[0].in6, s, sizeof(s));
                        blobmsg_add_string(&blob, (af == AF_INET) ? "ipaddr" : "ip6addr", s);
 
index 35c491da0aec81185e543f759e6cf2155b7f15e9..d20c6c111f99623c3a60d043d3b94b299517d7d6 100644 (file)
@@ -58,6 +58,7 @@ CBILease6Status = form.DummyValue.extend({
                                        E('th', { 'class': 'th' }, _('Hostname')),
                                        E('th', { 'class': 'th' }, _('IPv6 address')),
                                        E('th', { 'class': 'th' }, _('DUID')),
+                                       E('th', { 'class': 'th' }, _('IAID')),
                                        E('th', { 'class': 'th' }, _('Lease time remaining'))
                                ]),
                                E('tr', { 'class': 'tr placeholder' }, [
@@ -1417,6 +1418,7 @@ return view.extend({
                                                                        host || '-',
                                                                        lease.ip6addrs ? lease.ip6addrs.join('<br />') : lease.ip6addr,
                                                                        lease.duid,
+                                                                       lease.iaid,
                                                                        exp
                                                                ];
                                                        }),
index 61cfc62ac0646b6043e03f6c2edac2190f329576..a98906f9fe25a1cd75ec399fe003b80bf70734bd 100644 (file)
@@ -135,6 +135,7 @@ return baseclass.extend({
                                E('th', { 'class': 'th' }, _('Host')),
                                E('th', { 'class': 'th' }, _('IPv6 address')),
                                E('th', { 'class': 'th' }, _('DUID')),
+                               E('th', { 'class': 'th' }, _('IAID')),
                                E('th', { 'class': 'th' }, _('Lease time remaining')),
                                isReadonlyView ? E([]) : E('th', { 'class': 'th cbi-section-actions' }, _('Static Lease'))
                        ])
@@ -164,6 +165,7 @@ return baseclass.extend({
                                host || '-',
                                lease.ip6addrs ? lease.ip6addrs.join('<br />') : lease.ip6addr,
                                lease.duid,
+                               lease.iaid,
                                exp
                        ];